package it.polimi.comorazio.data;

import android.content.Context;
import android.database.Cursor;

public class AllPointsOfInterestLoader extends SimpleCursorLoader {

	private final ForceLoadContentObserver mObserver = new ForceLoadContentObserver();
	private DataBaseHelper dbHelper;

	public AllPointsOfInterestLoader(Context context, DataBaseHelper dbHelper) {
		super(context);
		this.dbHelper = dbHelper;
	}

	@Override
	public Cursor loadInBackground() {
		Cursor c = dbHelper.getAllPointsOfInterest();

		if (c != null) {
			// Ensure the cursor window is filled
			c.getCount();
			c.registerContentObserver(mObserver);
		}

		return c;
	}

}
